import Vue from 'vue';
import Vuex from 'vuex'

Vue.use(Vuex);
let DEFAULT = '合肥';

try {
  if(localStorage['city']){
    DEFAULT =localStorage['city']
  }
}catch (e){
  console.log(e)
}
export default new Vuex.Store({
  state:{
      city: DEFAULT
    },
  actions:{
    changeCities(ctx,city){
      ctx.commit('changeCities',city)
    }
  },
  mutations:{
    changeCities(state,city){
      state.city = city;
      try {
        localStorage['city'] = city
      } catch (e){
        console.log(e)
      }
    }
  }
})
